<template>
  <a-card :bordered="false" style="overflow-y: auto">
    <a-tabs defaultActiveKey="1">
      <a-tab-pane tab="流程控制条件" key="1">
        <a-form>
          <a-form-item v-for="(value,index) in dictItems"
            :labelCol="labelCol"
            :wrapperCol="wrapperCol"
            :label="value.dictName">
            <a-radio-group   style="margin-left: 10px" @change="itemChange" v-model="value.dictCode1">
              <a-radio :value="value.dictCode + ',' + v.itemValue" v-for="(v,i) in value.itemObj" >
                {{v.itemName}}
              </a-radio>
            </a-radio-group>
          </a-form-item>
        </a-form>
      </a-tab-pane>
    </a-tabs>
  </a-card>
</template>

<script>
  import { httpAction,getAction } from '@/api/manage'

  export default {
    name: 'ProcessNodeControl',
    // props: {
    //   dictItems: Array,
    // },
    data(){
      return{
        dictItems:[],
        showRadio:false,
        valueItem: "",
        itemRtn: [],
        labelCol: {
          xs: { span: 24 },
          sm: { span: 2 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        // dictItems: [],
        url: {
          queryExpendById: '/base/tpExpenditureAllocationInfo/queryById',
          getDictItemMsgByDictCode: '/sys/dict/getDictItemMsgByDictCode',
        }
      }
    },
    created() {
      this.itemChange()
    },
    methods: {
      /**
       * 高丰
       * 初始化流程分支配置按钮的初始化,editModal中调用此方法
       * **/
      dicts(val){
        this.dictItems=val
        for (let i = 0; i < val.length; i++) {
          this.dictItems[i].dictCode1 = ''
        }
        this.itemChange()
      },
      /**
       * 数据流程分支数据回显
       * @param e
       */
      processBranchs(val){
        console.log(val,val,'vvvvvvvvvvvvvvv')
        let branchs=''
        for (let i = 0; i < val.length; i++) {
          let branch=val[i].branchValue
          let dictList= branch.split('.')
          let dictObj=dictList[0]
          let dictBranch=dictList[1]
          branchs =dictObj+','+dictBranch
          this.dictItems[i].dictCode1 =branchs
        }
      },
      itemChange(){
        // console.log(this.dictItems,'123321')
        // if(e.target.value){
        //   let obj = {
        //     itemName: e.target.value.split(',')[0],
        //     itemValue: e.target.value.split(',')[1]
        //   }
        //   //判断数组中是否是值，如果没有新增一条
        //   if(this.itemRtn.length == 0){
        //     this.itemRtn.push(obj)
        //   }else{ //如果数组中有值，判断一下数组中是否包含了同一个类型的数据，如果有更新，没有新增
        //     for(let i=0;i<this.itemRtn.length;i++){
        //       if(this.itemRtn[i].itemName == obj.itemName){
        //         this.itemRtn[i] = obj //为了更新成最新选择的项
        //       }else{
        //         this.itemRtn.push(obj)
        //       }
        //     }
        //   }
        // }
        this.$emit('chooseItemRtn',this.dictItems)
      },

    }
  }
</script>

<style scoped>

</style>